import request from './request'

let BaseUrl = '/api/users'


// 用户注册
export const userRegister = (data)=>{
    return  request({url:BaseUrl+'/register', method:'post', data})
}

// 用户登录
export const userLogin = (data)=>{
    return request({url:BaseUrl+'/login', method:'post', data})
}

// 获取用户信息
export const getMyInformation = (user_address)=>{
    return request({url:BaseUrl+'/getMyInformation', method:'post', data:{user_address}})
}

// 获取其他人的用户信息
export const getOtherInformation = (user_address, other_address)=>{
    return request({url:BaseUrl+'/visitOtherInformation', method:'post', data:{user_address, other_address}})
}

// 关注艺术家
export const focusUser = (focus_user_id)=>{
    return request({url:BaseUrl + '/focus_user', method:'post', data:{focus_user_id}})
} 

// token 解密
export const decodeUserAddress = (token)=>{
    return request({url:BaseUrl + '/decodeUser_address', headers:{authorization:token}, method:'post'})
}

// 创建合集
// "title": "token测试", 
// "logo": "hash", 
// "info": "test2" 
export const insertArray = (data)=>{
    return request({url:BaseUrl + '/insertArray', method:'post', data})
}


// 获取关注列表
export const getMyFocus = (pageIndex, pageSize)=>{
    return request({url:BaseUrl + '/getMyFocus', method:'post', data:{pageIndex, pageSize}})
}

// 获取个人的合集
export const getOwnerArray = (pageIndex, pageSize)=>{
    return request({url:BaseUrl + '/getOwnerArray', method:'post', data:{pageIndex, pageSize}})
}

// 获取个人信息
export const getInformationById = (id)=>{
    return request({url:BaseUrl + '/getInformationById', method:'post', data:{id}})
}

// 更新背景图
export const updateBackground = (id, background)=>{
    return request({url:BaseUrl + '/updateBackground', method:'post', data:{id, background}})
}

// 修改合集信息
export const updateArray = (data)=>{
    return request({url:BaseUrl + '/updateArray', method:'post', data})
}

// 修改个人信息
// "introduction": "测试213", 
// "logo": "hash值2", 
// "username": "22", 
// "nickname": "2" 
export const updateInformation = (data)=>{
    return request({url:BaseUrl + '/updateInformation', method:'post', data})
}

// 修改密码
export const updatePass = (oldpass, newpass)=>{
    return request({url:BaseUrl + '/updatePass', method:'post', data:{oldpass, newpass}})
}

// 添加商品到合集
export const addArrayShop = (shop_ids, array_id)=>{
    return request({url:BaseUrl + '/AddArrayShop', method:'post', data:{shop_ids, array_id}})
}

// 删除合集中的商品
export const delArrayShop = (ids)=>{
    return request({url:BaseUrl + '/delArrayShop', method:'post', data:{ids}})
}

// 查看拒绝理由
export const queryreason = (id)=>{
    return request({url:BaseUrl + '/queryreason', method:'post', data:{id}})
}

// 删除未过审的商品
export const delShopByRefushed = (id) => {
    return request({url:BaseUrl + '/delShopByRefushed', method:'post', data:{id}})
}

// // 测试接口
// async function test(){
//     let result = await decodeUserAddress('Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2NDkwMDY1NjgsImRhdGEiOiIweDc4ZWJlODhiNkRBNkY3OWQ4NTE5NzlDRDM0OTIzMTkzN2VFQjljNTMiLCJpYXQiOjE2NDg5OTkzNjh9.PMBfCFweSuT-UfDj54SpyNoO8uTufirR8m5wb3xmZns')
//     console.log(result)
// }
// test()
